import React,{useState,useEffect} from "react";
import {  ScrollView,View} from 'react-native';
import Headers from '@/app/components/header/Headers';
import {getNoticeDetailList} from './serve'
import HTMLView from 'react-native-htmlview';
import { useRoute } from "@react-navigation/native";
import {size} from '@/app/utils';
const NoticeDeatilScreen = (props:any) => {
    let [opciaty,setOpciaty] = useState(0);
    let [title,setTitle] = useState(0);
    let [content,setContent] = useState(null);
    let route = useRoute();

    useEffect(()=>{
        let params:any = (route && route.params) ? route.params : {};
        setTitle(params.title)
        getInit(params.id);
    },[])

    const getInit=(id:number|string)=>{
        getNoticeDetailList(id).then((res)=>{
            let data = res.data||{};
            setContent(data.content)
        }).catch(()=>{

        })
    }

    return(
        <View style={{ flex: 1,flexDirection:'column'}}>
            <Headers
                title={title}
                border={false}
                barStyle={0}
                leftIcon={require('@/assets/images/icon/back.png')}
                rightIcon={require('@/assets/images/home/2.png')}
                leftTitle={''}
                backgroundColor={`rgba(255,255,255,${opciaty})`}
                centerColor={'#666'}
                {...props}
            />
            <View style={{flex: 1,}}>
                <ScrollView 
                    style={{paddingLeft:size(20),paddingRight:size(20),paddingTop:size(20)}}
                >
                    <HTMLView
                        value={content || ''}
                    />
                </ScrollView>
            </View>
        </View>
    )
}

export default NoticeDeatilScreen